import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:rc_app/pages/container_page.dart';
import 'package:rc_app/pages/web_view_page.dart';
import 'package:rc_app/pages/work/alarm_handle.dart';

class Router {
  static const homePage = 'app://';
  static const alarmHandle = 'app://work/alarmHandle';
  Widget _getPage(String url, dynamic params) {
    if (url.startsWith('https://') || url.startsWith('http://')) {
      return WebViewPage(url, params: params);
    } else {
      switch (url) {
        case homePage:
          return ContainerPage();
        case alarmHandle:
          return AlarmHandle(pageType: params['pageType'],);
      }
    }
    return null;
  }
  Router.pushNoParams(BuildContext context, String url) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, null);
    }));
  }
  Router.push(BuildContext context, String url, dynamic params) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, params);
    }));
  }
}
